package JasPerl::JSTL::Core::Config;

use 5.010;
use strict;
use warnings;

use parent qw(Exporter);

our @EXPORT_OK = qw{
    FMT_FALLBACK_LOCALE FMT_LOCALE FMT_LOCALIZATION_CONTEXT FMT_TIME_ZONE
    SQL_DATA_SOURCE SQL_MAX_ROWS
};

our %EXPORT_TAGS = (
    fmt => [ qw(FMT_FALLBACK_LOCALE FMT_LOCALE FMT_LOCALIZATION_CONTEXT FMT_TIME_ZONE) ],
    sql => [ qw(SQL_DATA_SOURCE SQL_MAX_ROWS) ]
);

use constant {
    FMT_FALLBACK_LOCALE      => 'javax.servlet.jsp.jstl.fmt.fallbackLocale',
    FMT_LOCALE               => 'javax.servlet.jsp.jstl.fmt.locale',
    FMT_LOCALIZATION_CONTEXT => 'javax.servlet.jsp.jstl.fmt.localizationContext',
    FMT_TIME_ZONE            => 'javax.servlet.jsp.jstl.fmt.timeZone',
    SQL_DATA_SOURCE          => 'javax.servlet.jsp.jstl.sql.dataSource',
    SQL_MAX_ROWS             => 'javax.servlet.jsp.jstl.sql.maxRows'
};

sub find {
    my ($class, $context, $name) = @_;
    return $context->find_attribute($name);
}

sub get {
    my ($class, $context, $name, $scope) = @_;
    return $context->get_attribute($name, $scope);
}

sub set {
    my ($class, $context, $name, $value, $scope) = @_;
    $context->set_attribute($name, $value, $scope);
}

sub remove {
    my ($class, $context, $name, $scope) = @_;
    $context->set_attribute($name, undef, $scope);
}

1;
